package com.sgzn.sgpay.enums;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 订单类型
 * @author huangsenguang
 */
public enum OrderTypeEnum {
    PAY("PAY","支付充值"),
    INCREASE_CREDIT("INCREASE_CREDIT","上分"),
    ;
    @Getter
    private String code;

    @Getter
    private String desc;

    private OrderTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }


    private static final Map<String, String> map = new HashMap<String, String>();

    static{
        for(OrderTypeEnum single : OrderTypeEnum.values()){
            map.put(single.code, single.desc);
        }
    }

    /**
     * 根据编码码获取类型
     * @param code
     * @return
     */
    public static String getDescByCode(String code) {
        if(isContain(code)){
            return map.get(code);
        }
        return code+"未定义";
    }

    public static boolean isContain(String code){
        if(map.containsKey(code)){
            return true;
        }
        return false;
    }

}

